<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:v-popover="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>商品分类管理</title>
    <link rel="stylesheet" href="../../../../static/css/element.css" th:href="@{/css/element.css}">
    <link rel="stylesheet" href="../../../../static/css/global.css" th:href="@{/css/global.css}"/>
    <link rel="stylesheet" href="../../../../static/css/main.css" th:href="@{/css/main.css}"/>
    <link rel="stylesheet" href="../../../../static/css/myelement.css" th:href="@{/css/myelement.css}"/>
    <script src="../../../../static/js/vue.js" th:src="@{/js/vue.js}"></script>
    <script src="../../../../static/js/element.js" th:src="@{/js/element.js}"></script>
    <script src="../../../../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
    <script src="../../../../static/js/jquery.nestable.js" th:src="@{/js/jquery.nestable.js}"></script>
</head>
<body>
<div id="app">
    <div class="main-content" v-cloak>
        <!-- 页面头部 -->
        <div class="page-header">
            <h1 class="page-title">商品分类管理</h1>
            <div class="z-pop_question">
                <el-popover
                        ref="popoverq"
                        placement="bottom-start"
                        width="400"
                        trigger="hover">
                    <p class="z-jiao">
                        1. 查看商户列表
                        2. 点击管理商品分类，进行商品分类管理
                        <a href="javascript:;">查看更多帮助</a>
                    </p>
                </el-popover>
                <i v-popover:popoverq class="el-icon-question"></i>
            </div>
            <div class="breadcrumb"><a href="javascript: top.location.reload();">首页</a><span>/</span>商品<span>/</span>商品分类管理</div>
        </div><!-- 页面头部 end -->

        <div class="list-content">
            <!--条件筛选-->
            <div class="content_item_filter clearfix" :class="[hasfilterMore?'content_filter_more':'']">
                <div class="input-select fl btn-radid_none">
                    <div class="filter-form filter-form-one clearfix">
                        <el-input placeholder="商户名称" v-model="conditions.vendorUuid.value" clearable class="minW40 z_input-holder"></el-input>
                        <!--<el-select placeholder="所属商户" v-model="conditions.vendorUuid.value" clearable class="z_select-holder">
                            <el-option v-for="vendor in vendorList"
                                       :key="vendor.value"
                                       :label="vendor.name"
                                       :value="vendor.value">
                            </el-option>
                        </el-select>-->
                    </div>
                    <div class='filter-form filter-form-more clearfix' v-show="filterMore"></div>
                    <div class="filter-operate">
                        <div class="filter-more" @click="toggleMoreSearch" v-show="hasfilterMore"><i :class="[filterMore?'el-icon-arrow-up':'el-icon-arrow-down']"></i></div>
                        <el-tooltip class="item" content="查询" placement="bottom-start">
                            <el-button icon="el-icon-search" @click="handleQuery"></el-button>
                        </el-tooltip>
                        <el-tooltip class="item" content="清空" placement="bottom-start">
                            <el-button icon="el-extend-clean" @click="handleClear"></el-button>
                        </el-tooltip>
                    </div>
                </div>
                <div class="filter-btn fr">
                    <!--<el-button type="primary" @click="showDailog">新增桌台分类</el-button>-->
                </div>
            </div>

            <!--主体表格-->
            <div class="z-tables">
                <el-table ref="multipleTable" :data="vendorList" style="width: 100%;">
                    <el-table-column fixed label="序号" type="index" class-name="z-opt_btn"></el-table-column>
                    <el-table-column prop="vendorName" label="商户名称" min-width="120"></el-table-column>
                    <el-table-column prop="vendorTypeName" label="商户类型" min-width="120"></el-table-column>
                    <el-table-column prop="industryName" label="所属行业" min-width="120"></el-table-column>
                    <el-table-column prop="mobile" label="联系电话" min-width="120"></el-table-column>
                    <el-table-column prop="createTime" label="创建时间" min-width="180"></el-table-column>
                    <el-table-column fixed="right" label="操作">
                        <template slot-scope="scope">
                            <el-button type="text" @click="productManage(scope.$index, scope.row)">管理商品分类</el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>

            <!--分页-->
            <div class="grid-content">
                <div class="bg-purple-light">
                    <el-pagination
                            @size-change="handleSizeChange"
                            @current-change="handleCurrentChange"
                            :current-page="currentPage"
                            :page-sizes="pageSizeList"
                            :page-size="pageSize"
                            layout="total, sizes, prev, pager, next"
                            :total="totalNum">
                    </el-pagination>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script th:inline="javascript">
    app = new Vue({
        el: "#app",
        data: {
            loading: true,
            openText: "",
            dialogFormVisible: false,
            vendorList:[],
            valueId: '',
            valueState: '',
            tableAllCheck: false,  // table 下方批量操作全选
            hasfilterMore: false,  // 列表是否拥有更多筛选条件
            filterMore: false,  // 列表更多筛选条件是否展示
            conditions: {
                "vendorUuid": {
                    "operation": "EQ",
                    "value": undefined
                }
            },
            dialogVisible: false,
            pageSizeList: [5, 10, 20, 50],
            totalNum: 0,
            currentPage: 1, //当前页码数
            pageSize: 10,
            passwordForm: {
                id: '',
                password: '111111'
            },
            dinnertablecate:{},
            rules: {
                password: [
                    {required: true, message: "请输入登录密码", trigger: 'blur'},
                    {min: 6, max: 20, message: '密码长度6到20个字符', trigger: 'blur'}
                ]
            },
        },
        created: function () {
            queryList();
        },
        methods: {
            dislogHide: function () {
                this.dialogFormVisible = false;
            },

            identityFormatter: function (row, column, cellValue, position) {
                for (let identity of this.identityList) {
                    if (identity.value === cellValue) {
                        return identity.name;
                    }
                }
            },
            handleSizeChange: function (val) {
                this.pageSize = val;
                queryList();
            },
            handleCurrentChange: function (val) {
                this.currentPage = val;
                queryList();
            },
            handleQuery() {
                this.currentPage = 1;
                queryList();
            },
            handleClear() {
                this.conditions.entityNo.value = undefined;
                this.conditions.state.value = undefined;
            },

            handleCommand(command) {
                this.$message('click on item ' + command);
            },
            // 列表批量操作2-批量导出
            handleCommand2(command) {
                this.$message('click on item ' + command);
            },
            tableAllCheckFn(rows) {
                if (rows) {
                    rows.forEach(row => {
                        this.$refs.multipleTable.toggleRowSelection(row, this.tableAllCheck)
                    })
                }
            },
            toggleMoreSearch() {
                this.filterMore = !this.filterMore;
            },
            productManage(index,row){
                let vendorUuid = row.uuid;
                window.location.href = "/backstage/cater/productcate/tolist?vendorUuid="+vendorUuid;
            }
        }
    });

    function queryList() {
        app.loading = true;
        let queryMessage = {
            "queryPage": app.currentPage,
            "pageShow": app.pageSize,
            "queryParams": app.conditions,
            "sortMap": {
                "uuid": "desc"
            }
        };
        $.ajax({
            url: "/backstage/cater/productcate/vendorlist",
            type: "POST",
            data: JSON.stringify(queryMessage),
            contentType: "application/json;charset=UTF-8",
            dataType: "json",
            success: function (data) {
                if (data && data.returnCode === 1) {
                    app.vendorList = data.returnMessage;
                    app.totalNum = data.pager.totalNum;
                }
                app.loading = false;
            }
        });
    }
</script>
</html>